Fixes for upstream-pr option - #20817
Merged
Merged
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideMakes upstream PR filename-to-rule matching case-insensitive and normalizes matched rule components to lowercase so tests are correctly collected when using the --upstream-pr option. Sequence diagram for pytest collection with upstream-pr case-insensitive matchingsequenceDiagram
actor Developer
participant Pytest as PytestRunner
participant UpstreamPR as UpstreamPROptionHandler
participant RuleSet as RuleSet
participant Matcher as match_file_to_rule
participant Components as ComponentSet
Developer->>Pytest: run pytest --upstream-pr foreman/PR_ID
Pytest->>UpstreamPR: parse --upstream-pr option
UpstreamPR->>RuleSet: load rules from ROBOTTELO_GITHUB_REPOS__FOREMAN__RULES
Pytest->>UpstreamPR: pytest_collection_modifyitems(session, items, config)
loop for each filename in upstream PR
UpstreamPR->>RuleSet: iterate over rules
loop for each rule
UpstreamPR->>Matcher: match_file_to_rule(filename, rule)
Matcher->>Matcher: re.search(rule.path, filename, IGNORECASE)
Matcher-->>UpstreamPR: True or False
alt filename matches rule
UpstreamPR->>Components: components.add(rule.component.lower())
UpstreamPR->>UpstreamPR: mark filename as processed
end
end
end
UpstreamPR-->>Pytest: components associated with items
Pytest-->>Developer: collected tests filtered by components
Class diagram for upstream_pr matching and collection helpersclassDiagram
class Rule {
+str path
+str component
}
class UpstreamPROptionHandler {
+pytest_collection_modifyitems(session, items, config)
-set components
-set unprocessed_filenames
-set matched_filenames
}
class Matcher {
+match_file_to_rule(filename, rule) bool
}
class ComponentSet {
+add(component)
+__contains__(component) bool
}
UpstreamPROptionHandler --> Rule : uses
UpstreamPROptionHandler --> Matcher : calls
UpstreamPROptionHandler --> ComponentSet : stores components
Matcher --> Rule : reads path and component
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
tpapaioa
force-pushed
the
upstream_pr_fixes
branch
from
March 16, 2026 13:07
d12cc51 to
e381bad
Compare
tpapaioa
marked this pull request as ready for review
March 16, 2026 13:33
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider normalizing
rule.componentto lowercase at rule creation/parsing time instead of during collection so the component casing is consistent throughout the codebase and you avoid repeated.lower()calls in the hot path. - You might want to move the
re.IGNORECASEflag into wherever the regex/pattern is first constructed (e.g., precompiling the pattern with the desired flags) to avoid passing flags on everyre.searchcall and to keep matching behavior defined in a single place.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider normalizing `rule.component` to lowercase at rule creation/parsing time instead of during collection so the component casing is consistent throughout the codebase and you avoid repeated `.lower()` calls in the hot path.
- You might want to move the `re.IGNORECASE` flag into wherever the regex/pattern is first constructed (e.g., precompiling the pattern with the desired flags) to avoid passing flags on every `re.search` call and to keep matching behavior defined in a single place.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
tpapaioa
force-pushed
the
upstream_pr_fixes
branch
from
March 20, 2026 15:16
e381bad to
8db8209
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Statement
--upstream-proptionSolution
Related Issues
SAT-24770
PRT test Cases example
Summary by Sourcery
Make upstream pull request file matching case-insensitive and normalize matched components to lowercase.
Bug Fixes:
Enhancements:
Summary by Sourcery
Ensure upstream pull request rules match file paths case-insensitively and normalize matched components for consistent test selection.
Bug Fixes:
Enhancements: